package com.yangzihao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yangzihao.entity.Menu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface MenuMapper extends BaseMapper<Menu> {

    @Select("SELECT \n" +
            "\t\tDISTINCT\t m.perms\n" +
            "FROM\n" +
            "  sys_user_role ur  \n" +
            "\tINNER JOIN sys_role r on ur.role_id=r.id\n" +
            "  INNER JOIN sys_role_menu rm on rm.role_id=r.id\n" +
            "  INNER JOIN sys_menu m on m.id =rm.menu_id\n" +
            "WHERE r.`status`=0 AND m.`status`=0 AND ur.user_id=#{userId}")
    List<String> selectPermsByUserId(@Param("userId") Long userId);

}
